import asyncio
import websockets
import json

async def send_json():
    uri = "ws://192.168.2.125:9999"
    async with websockets.connect(uri) as websocket:
        # 创建要发送的JSON数据
        data = {
        "Name": "AbdominalMotor",
        "MotorNum": 1,
        "Angle": -10
    }
        json_data = json.dumps(data)  # 将Python字典转换为JSON字符串
        
        # 发送JSON数据
        await websocket.send(json_data)
        print("Sent:", json_data)

# 使用 asyncio.run 来确保任务执行完后脚本自动结束
asyncio.run(send_json())
